<template>
	<view class="content">
		<!-- 添加按钮 -->
		<view class="add-button-container">
            <button @click="goToAddPage">添加</button>
        </view>
		
		<view v-for="(item, index) in data.items" :key="index" class="item">
			<!-- 这里可以根据数据结构调整展示内容 -->
\

			$-LISTITEM-$ <!--model.comments:model.field-->


		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			title: '$-TABLENAME-$List',
			data: {
				total: 0,
				page: 1,
				limit: 10,
				pages: 1,
				items: []
			}
		}
	},
	onLoad() {
		this.getList();
	},
	methods: {
		getList() {
			var url = "http://localhost:3000/$-TABLENAME-$/list"
			uni.request({
				url: url,
				method: 'GET', // 根据实际情况修改请求方法
				success: (res) => {
					if (res.statusCode === 200) {
						this.data = res.data.data;
					} else {
						console.error('请求失败，状态码：', res.statusCode);
					}
				},
				fail: (err) => {
					console.error('请求发生错误：', err);
				}
			});
		},
		        // 跳转到添加页面的方法
		goToAddPage() {
            uni.navigateTo({
                url: '/pages/$-TABLENAME-$/add'
            });
        }
	}
}
</script>

<style>
.content {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}
.add-button-container {
    margin-bottom: 20px;
}
.logo {
	height: 200rpx;
	width: 200rpx;
	margin-top: 200rpx;
	margin-left: auto;
	margin-right: auto;
	margin-bottom: 50rpx;
}

.text-area {
	display: flex;
	justify-content: center;
}

.title {
	font-size: 36rpx;
	color: #8f8f94;
}
.item {
    padding: 20px 15px;
    border-bottom: 1px solid #ccc;
    word-wrap: break-word;
    word-break: break-all;
}
</style>
